package CheckPermutation;

import java.util.Arrays;

public class Solution {
    public boolean CheckPermutation(String s1, String s2) {
        if(s1.length()!=s2.length())return false;
        int[] cnt = new int[26];
        for (int i = 0; i < s1.length(); i++) {
            cnt[s1.charAt(i)-'a']++;
        }
        for (int i = 0; i < s2.length(); i++) {
            if(cnt[s2.charAt(i)-'a'] == 0) return false;
            cnt[s2.charAt(i)-'a']--;
        }
        return Arrays.stream(cnt).sum() == 0;
    }
}
